import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {NzModalRef} from 'ng-zorro-antd/modal';

interface Detail {
  id: number;
  name: string;
  url: string;
  remark: string;
}

@Component({
  selector: 'app-preview-option-img-remark',
  templateUrl: './preview-option-img-remark.component.html',
  styleUrls: ['./preview-option-img-remark.component.scss']
})
export class PreviewOptionImgRemarkComponent implements OnInit {
  // 要展示的选项数据
  @Input() details: Detail[] = [];
  // 当前展示的序号
  @Input() index = 0;

  constructor(
    private nzModalRef: NzModalRef
  ) {
  }

  ngOnInit(): void {
  }

  currentImgIndexChange(op: 'plus' | 'minus') {
    const length = this.details.length;
    if (op === 'plus') {
      this.index += 1;
    } else if (op === 'minus') {
      this.index -= 1;
    }
    if (this.index === length) {
      this.index = 0;
    } else if (this.index < 0) {
      this.index = length - 1;
    }
  }

  hideModal() {
    this.nzModalRef.destroy();
  }
}
